package com.my.study.config.hook.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Arrays;

/**
 * <p>Bean初始化完成扩展点</p>
 *
 * <p>@PostConstruct注解一般放在Bean的方法上，被@PostConstruct修饰的方法会在Bean初始化后马上调用
 * </P>
 *
 * @author: yidujun
 * @create: 2021/04/02 15:58
 */
@Component
@Slf4j
public class PostConstructExampleBean {

    @Autowired
    private Environment environment;

    @PostConstruct
    public void init() {
        String[] strings = environment.getDefaultProfiles();
        log.info("PostConstructExampleBean -> {}", Arrays.asList(strings));
    }

}
